
ticketHub.controller('interOrderManageCtrls',function($scope,$http){
	
	$scope.orderID="";//订单编号
	$scope.fromDate="";//下单起始日期
	$scope.toDate="";//下单结束日期
	$scope.pnr="";//PNR号
	$scope.passengerName="";//乘客姓名
	$scope.ticketNo="";//票号
	$scope.orderType="all";//订单类型(正常、取消、改签等)
	$scope.orderSubType="all";//订单类型的细分子类型
	$scope.loginUserName="";//采购商用户登录名
	$scope.source = "PSSA";//按渠道查询
	$scope.page="";//页码
	$scope.fetchDate="";//京杭下单时间
	/*封装函数页面加载时加载列表数据*/
	$scope.query=function(){
		layer.load(3,{shadeClose:true});
		var postData = {};
		if($scope.source=="JHAD"){
			postData = {
					"source":$scope.source,
					"fetchDate":$scope.fetchDate+" 00:00:00",
					"startOrderId":""
				}
			getAjax(postData)
		}else{
			//alert($scope.source)
			postData = {
					"loginUserName": $scope.loginUserName, 
				    "orderEndDay": $scope.toDate, 
				    "orderID": $scope.orderID, 
				    "orderStartDay": $scope.fromDate, 
				    "orderSubType": $scope.orderSubType, 
				    "orderType": $scope.orderType, 
				    "page": 1, 
				    "passengerName": $scope.passengerName, 
				    "pnr": $scope.pnr, 
				    "source":$scope.source,
				    "ticketNo": $scope.ticketNo
				}
			getAjax(postData)
		}
	}
	$scope.JHAD = function(){
		if($scope.source=="JHAD"){
			return true;
		}else{
			return false;
		}
	}
	$scope.JHADNextPage = function(){
		var length = $scope.orderList.length;
		var startOrderId = $scope.orderList[length-1].orderID;
		postData = {
			"source":$scope.source,
			"fetchDate":$scope.fetchDate+" 00:00:00",
			"startOrderId":startOrderId
		}
		getAjax(postData)
	}
	
	
	
	function getAjax(postData){
		$http({
			url:'../order/interList',
			method:'post',
			data:postData
		})
		.then(function(data){
			layer.closeAll();
			if(data.data.status==1001){
				if(data.data.data.orderListQueryCommonResponse.totalCount=="0"){
					$scope.orderList="";
					layer.alert("查询结果为空");					
				}else{
					$scope.orderList=data.data.data.orderListQueryCommonResponse.orderList;
				}				
			}
			if(data.data.status==1002){
				layer.alert("错误返回 "+data.data.message)
				$scope.orderList="";
				return false;
			}
			
		})
	}
})
	
	
